<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 字符长度大于3位显示省略...
        var arr = [
            "添加了附近",
            "字符长度超过三位",
            "好友"
        ]
        // var res=[]
        // arr.forEach(item=>{
        //     if(item.length>3){
        //         var item = item.substr(0,3)+'...';
               
        //     } res.push(item)
        // })
        // console.log(res)
        var res = arr.map(item=>{
            if(item.length>3){
                item = item.substr(0,3)+"..."
            }
            return item;
        })
        console.log(res)
    </script>
</body>
</html>